package cn.darksoul3.spark.operator

import org.apache.spark.{SparkConf, SparkContext}

object ForeachPartition {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName("ForeachPartition").setMaster("local[*]")

    val sc = new SparkContext(conf)

    val rdd1 = sc.parallelize(List(1, 2, 3, 4, 5, 6, 7), numSlices = 2)
    rdd1.foreachPartition(it => {
      it.foreach(println)
    })

    sc.stop()

  }
}
